package com.anjie.powerproject.map.impl;

import com.anjie.powerproject.entity.Device;
import com.anjie.powerproject.map.DeviceMap;
import com.anjie.powerproject.pojo.dto.DeviceDTO;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class DeviceMapImpl implements DeviceMap {

    @Override
    public DeviceDTO toDTO(Device device) {
        if ( device == null ) {
            return null;
        }

        DeviceDTO deviceDTO = new DeviceDTO();

        deviceDTO.setDevId( device.getDeviceId() );
        deviceDTO.setDevCode( device.getTemperatureCode() );
//        deviceDTO.setTmpCode(device.getTemperatureCode());

        return deviceDTO;
    }

    @Override
    public List<DeviceDTO> toDTO(List<Device> devices) {
        if ( devices == null ) {
            return null;
        }

        List<DeviceDTO> list = new ArrayList<DeviceDTO>( devices.size() );
        for ( Device device : devices ) {
            list.add( toDTO( device ) );
        }

        return list;
    }
}
